package com.ygqh.baby.service.impl;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.foxinmy.weixin4j.mp.token.WeixinTokenCreator;
import com.foxinmy.weixin4j.token.TokenHolder;
import com.ygqh.baby.service.WxMpAuthorityService;
import com.ygqh.baby.service.WxTokenStorager;

@Service
public class WxMpAuthorityServiceImpl implements WxMpAuthorityService {

	protected final Logger logger = Logger.getLogger(this.getClass());

	@Value("${micro.msg.appId}")
	protected String appId;
	@Value("${micro.msg.secret}")
	protected String appSecret;
	@Autowired
	private WxTokenStorager tokenStorager;
	
	@Override
	public TokenHolder findTokenHolder() {
		WeixinTokenCreator weixinTokenCreator = new WeixinTokenCreator(appId, appSecret);
		TokenHolder tokenHolder = new TokenHolder(weixinTokenCreator, tokenStorager);
		return tokenHolder;
	}

}
